M[Symbol.asyncDispose]
Bun

method

worker_threads.Worker.[Symbol.asyncDispose]

[Symbol.asyncDispose](): Promise<void>;

Calls worker.terminate() when the dispose scope is exited.

async function example() {
  await using worker = new Worker('for (;;) {}', { eval: true });
  // Worker is automatically terminate when the scope is exited.
}